//
//  TaxiCompanyController.m
//  NZTaxi
//
//  Created by Allan Vergara on 26/11/11.
//  Copyright (c) 2011 List-it. All rights reserved.
//

#import "TaxiCompanyController.h"
#import "TaxiCompanyView.h"

@implementation TaxiCompanyController

@synthesize companyPicker;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    taxiCompanies = [[NSMutableArray alloc] initWithCapacity:6];
    NSString *imgSource;
    
    TaxiCompanyView *view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"clover" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];    
    view.title = @"Clover Taxi";
    [taxiCompanies addObject:view];
    //[view release];
    
    view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"diamond" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];   
    view.title = @"Diamond Cabs";
    [taxiCompanies addObject:view];
    //[view release];
    
    view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"spade" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];   
    view.title = @"Aces of Spades";
    [taxiCompanies addObject:view];
    //[view release];
    
    view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"ruby" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];  
    view.title = @"Ruby Transport";
    [taxiCompanies addObject:view];
    //[view release];
    
    view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"hearts" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];   
    view.title = @"Hearts Taxis";
    [taxiCompanies addObject:view];
    //[view release];
    
    view = [[TaxiCompanyView alloc] initWithFrame:CGRectZero];
    imgSource = [[NSBundle mainBundle] pathForResource:@"school_board" ofType:@"png"];
    view.image = [UIImage imageWithContentsOfFile:imgSource];  
    view.title = @"School Cabs";
    [taxiCompanies addObject:view];
    //[view release];
    
    
    /*
    //UIImage *image;
    NSString *imgSource;
    
    
    [[NSBundle mainBundle] loadNibNamed:@"OrderTaxiTVC" 
                                  owner:self options:nil];
    
    
    TaxiCompanySelectionController *controller = [[TaxiCompanySelectionController alloc] 
                                                  initWithNibName:@"TaxiCompanySelectionController"
                                                  bundle:nil];
    
    imgSource = [[NSBundle mainBundle] pathForResource:@"clover" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];
    controller.label.text = @"Clover Taxis";
    [taxiCompanies addObject:controller];
    
    controller = [[TaxiCompanySelectionController alloc] 
                  initWithNibName:@"TaxiCompanySelectionController"
                  bundle:nil];
    imgSource = [[NSBundle mainBundle] pathForResource:@"diamond" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];    
    controller.label.text = @"Diamond Cabs";
    [taxiCompanies addObject:controller];
    
    controller = [[TaxiCompanySelectionController alloc] 
                  initWithNibName:@"TaxiCompanySelectionController"
                  bundle:nil];
    imgSource = [[NSBundle mainBundle] pathForResource:@"spade" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];
    controller.label.text = @"Aces of Spades";
    [taxiCompanies addObject:controller];
    
    controller = [[TaxiCompanySelectionController alloc] 
                  initWithNibName:@"TaxiCompanySelectionController"
                  bundle:nil];
    imgSource = [[NSBundle mainBundle] pathForResource:@"ruby" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];
    controller.label.text = @"Ruby Transport";
    [taxiCompanies addObject:controller];
    
    controller = [[TaxiCompanySelectionController alloc] 
                  initWithNibName:@"TaxiCompanySelectionController"
                  bundle:nil];
    imgSource = [[NSBundle mainBundle] pathForResource:@"hearts" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];
    controller.label.text = @"Hearts Rides";
    [taxiCompanies addObject:controller];
    
    controller = [[TaxiCompanySelectionController alloc] 
                  initWithNibName:@"TaxiCompanySelectionController"
                  bundle:nil];
    imgSource = [[NSBundle mainBundle] pathForResource:@"school_board" ofType:@"png"];
    controller.imageView.image = [UIImage imageWithContentsOfFile:imgSource];
    controller.label.text = @"School Cabs";
    [taxiCompanies addObject:controller];*/
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [companyPicker release];
    [super dealloc];
}

#pragma mark Picker DataSource/Delegate

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return [taxiCompanies count];
}

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row 
          forComponent:(NSInteger)component reusingView:(UIView *)view 
{
    return[taxiCompanies objectAtIndex:row]; 
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
  //  NSDictionary *optionForRow = [accuracyOptions objectAtIndex:row];
  //  [setupInfo setObject:[optionForRow objectForKey:kAccuracyValueKey] forKey:kSetupInfoKeyAccuracy];
}


-(IBAction)btnOKClick:(id)sender {
    [self.navigationController popViewControllerAnimated:TRUE];
}

@end
